package com.donleo.amqp.service;

import com.donleo.amqp.model.Book;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.MessageProperties;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Service;

/**
 * @author liangd
 * date 2020-12-12 11:19
 * code
 */
@Service
public class BookService {
    /**
     * 获取对象
     * @param book
     */
    @RabbitListener(queues = "donleo")
    public void testBook(Book book){
        System.out.println("接收消息"+book);
    }

    /**
     * 获取message消息
     * @param message
     */
    @RabbitListener(queues = "donleo.emps")
    public void testBoot01(Message message){
        byte[] body = message.getBody();
        MessageProperties properties = message.getMessageProperties();
        System.out.println(body);
        System.out.println(properties);
    }
}
